package demo2;

public class Computer {

    public void open(){
        System.out.println(" 电脑开机 ");
    }
    public void close(){
        System.out.println(" 电脑关机 ");
    }

    public void useDevice(IUSB usb){
        usb.openDevice();
        if(usb instanceof Mouse){
            ((Mouse)usb).click();
        } else if (usb instanceof Keyboard) {
            ((Keyboard)usb).inPut();
        } else if (usb instanceof Microphone) {
            ((Microphone)usb).adjustVolume();
        }
        usb.closeDevice();
    }

}
